<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="/WEB-INF/templates/template.xhtml">

	<ui:define name="title">#{resourceBundle['user.admin.title']}</ui:define>

	<ui:define name="body">
		<h:form>
			<h:panelGrid columns="3" width="60%">

				<h:outputText value="#{resourceBundle['user.admin.username']}:" />
				<h:inputText value="#{userModel.username}" id="username"
					label="#{resourceBundle['user.admin.username']}" size="60"
					autocomplete="off">
					<f:validateRequired />
					<f:validateLength maximum="10" />
					<rich:validator />
				</h:inputText>
				<rich:message for="username" />

				<h:outputText value="#{resourceBundle['user.admin.password']}:"
					rendered="#{userModel.newMode}" />
				<h:inputSecret value="#{userModel.password}" id="password"
					label="#{resourceBundle['user.admin.password']}" size="60"
					autocomplete="off" rendered="#{userModel.newMode}">
					<f:validateRequired />
					<f:validateLength maximum="255" />
					<rich:validator />
				</h:inputSecret>
				<rich:message for="password" rendered="#{userModel.newMode}" />

				<h:outputText value="#{resourceBundle['user.admin.firstName']}:" />
				<h:inputText value="#{userModel.firstName}" id="firstName"
					label="#{resourceBundle['user.admin.firstName']}" size="60">
					<f:validateRequired />
					<f:validateLength maximum="255" />
					<rich:validator />
				</h:inputText>
				<rich:message for="firstName" />

				<h:outputText value="#{resourceBundle['user.admin.lastName']}:" />
				<h:inputText value="#{userModel.lastName}" id="lastName"
					label="#{resourceBundle['user.admin.lastName']}" size="60">
					<f:validateRequired />
					<f:validateLength maximum="255" />
					<rich:validator/>
				</h:inputText>
				<rich:message for="lastName" />

				<h:outputText value="#{resourceBundle['user.admin.email']}:" />
				<h:inputText value="#{userModel.email}" id="email"
					label="#{resourceBundle['user.admin.email']}" size="60"
					validatorMessage="#{resourceBundle['user.admin.email.invalid']}">
					<f:validateRequired />
					<f:validateLength maximum="255" />
					<f:validateRegex pattern="^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$" />
					<rich:validator />
				</h:inputText>
				<rich:message for="email" />

			</h:panelGrid>

			<br />
			<br />

			<rich:dataTable var="role" value="#{userModel.rolesDataModel}"
				style="width:60%;">
				<f:facet name="header">
					<rich:columnGroup>
						<rich:column>
							<h:outputText value="#{resourceBundle['user.admin.roles']}" />
						</rich:column>
						<rich:column width="3%">
							<h:outputText value="" />
						</rich:column>
					</rich:columnGroup>
				</f:facet>
				<rich:column>
					<h:outputText value="#{role.wrapped.name}" />
				</rich:column>

				<rich:column>
					<h:selectBooleanCheckbox value="#{role.selected}">
						<a4j:ajax />
					</h:selectBooleanCheckbox>
				</rich:column>
			</rich:dataTable>

			<br />

			<a4j:commandButton value="#{resourceBundle['accept']}"
				action="confirm" />

			<a4j:commandButton value="#{resourceBundle['cancel']}"
				action="cancel" immediate="true" />
		</h:form>
	</ui:define>
</ui:composition>
</html>